package org.example.heap;
/**
 * -Xms60M -Xmx60M -XX:-DoEscapeAnalysis -XX:+PrintGCDetails -XX:+EliminateAllocations
 * 逃逸分析测试
 * @author youshang
 * @date 2022/03/23 16:12
 **/
public class ScalarReplace {

    public static void main(String[] args) {
        long start = System.currentTimeMillis();
        for (int i = 0; i < 10000000; i++) {
            alloc();
        }
        long end = System.currentTimeMillis();
        System.out.println(end - start);
        try {
            Thread.sleep(1000000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

    }

    public static class User{
        private int id;
        private String name;
    }

    static void alloc(){
        User user = new User();
        user.id = 6;
        user.name = "zs";
    }
}
